﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenSoftStore.BusinessLogic.Report;
using OpenSoftStore.Client.Common;

namespace OpenSoftStore.Client.UIL.ManageReport
{
    public partial class WorkReportByDay : UserControl
    {
        public ReportLogic reportBll;
        private static WorkReportByDay instance;
        public static WorkReportByDay Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new WorkReportByDay();
                }
                return instance;
            }
        }

        public WorkReportByDay()
        {
            reportBll = new ReportLogic();
            InitializeComponent();
            SPACommon.SetDataGridStyle(dgvWork);
            dgvWork.AutoGenerateColumns = false;
            var from = DateTime.Now.Date;
            var to = DateTime.Now.Date.AddDays(1);
            dgvWork.DataSource = reportBll.GetWorkReport(" where B.AddTime between #" + from + "# and #" + to + "#");
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            var from = dtpFrom.Value.Date;
            var to = dtpTo.Value.Date.AddDays(1);

            dgvWork.DataSource = reportBll.GetWorkReport(" where B.AddTime between #" + from + "# and #" + to + "#");
        }

        private void btnOutput_Click(object sender, EventArgs e)
        {
            SPACommon.ExportToExcel(dgvWork, "工作日报表");
        }
    }
}
